﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Configuration;

namespace EWDTAssignment.App_Code
{
    public class Email
    {
        public static bool sentEmail(string receiver,string title,string message)
        {
            bool result = false;
            try
            {
                MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["From"], receiver, title, message);
                SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailServer"], 587);
                smtp.EnableSsl = true;
                //smtp.Host=ConfigurationManager.AppSettings["MailServer"];
                smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["From"], ConfigurationManager.AppSettings["Password"]);
                smtp.Send(mail);
                result = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
    }
}